package cn.sumpu.app.guoguojie.web.mvc.misc;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.sumpu.app.guoguojie.biz.ImageBiz;
import cn.sumpu.app.guoguojie.util.Constant;
import cn.sumpu.app.guoguojie.util.ImageWeb;




@Controller
public class ImageUploadController {
	@Autowired
	private ImageBiz imageBiz;
	
	@RequestMapping(value = "/misc/upload/ueditorUp.htm")
	public String ueditorUp(HttpServletRequest request,HttpServletResponse response)throws IOException{
	
		response.setContentType("text/html; charset=UTF-8");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter pw = null; 
		try {
			ImageWeb imageWeb = imageBiz.uploadOneImg(request,Constant.IMAGE_PATH_UEDITOR);
			pw = response.getWriter();
			pw.print(JSONObject.fromObject(imageWeb));
		} catch (Exception e) {
			pw = response.getWriter();
			pw.print("error");
		}
		return null;
	} 
}
